import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { SWFInfo } from "../../../../com/gengine/resource/info/SWFInfo";
type int = number;
//class CutCounts
    
    export  class CutCounts /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.visible = false;
            LoaderManager.instance.load("cutcounts_progress.swf", this.onLoadedComplete);
            this.createChildren();
            return;
        }

        /* internal  */createChildren(): void
        {
            this._thousandsDigit = new Object /* flash.display.Bitmap */();
            this._thousandsDigit.x = -170;
            this._thousandsDigit.y = 12;
            this.addChild(this._thousandsDigit);
            this._hundredsDigit = new Object /* flash.display.Bitmap */();
            this._hundredsDigit.x = -120;
            this._hundredsDigit.y = 12;
            this.addChild(this._hundredsDigit);
            this._tensDigit = new Object /* flash.display.Bitmap */();
            this._tensDigit.x = -70;
            this._tensDigit.y = 12;
            this.addChild(this._tensDigit);
            this._unitsDigit = new Object /* flash.display.Bitmap */();
            this._unitsDigit.x = -20;
            this._unitsDigit.y = 12;
            this.addChild(this._unitsDigit);
            return;
        }

        /* internal  */onLoadedComplete(arg1: SWFInfo): void
        {
            this._progressBar = arg1.clip;
            this._progressBar.stop();
            this.addChildAt(this._progressBar, 0);
            return;
        }

        public setCutsNum(arg1: int, arg2: int): void
        {
            this._num = arg1;
            if (this._numsMc) 
            {
                this.setNums(this._num);
            }
            else 
            {
                LoaderManager.instance.load("cutcountsNums.swf", this.onNumsLoaded);
            }
            if (!this._timer) 
            {
                this._timer = new Object /* flash.utils.Timer */(100);
                this._timer.addEventListener(flash.events.TimerEvent.TIMER, this.onTimerEvent);
            }
            this._timer.delay = (arg2 - 1) * 1000 / 340;
            this._timer.stop();
            this._timer.reset();
            this._timer.start();
            if (!this.visible) 
            {
                this.visible = true;
            }
            return;
        }

        /* internal  */onTimerEvent(arg1: Object /* flash.events.TimerEvent */): void
        {
            var loc1=(arg1.target as Object /* flash.utils.Timer */).currentCount;
            if (this._progressBar) 
            {
                this._progressBar.gotoAndStop(loc1);
            }
            if (loc1 == 340) 
            {
                this._timer.stop();
                this._timer.reset();
                this.visible = false;
            }
            return;
        }

        /* internal  */onNumsLoaded(arg1: SWFInfo): void
        {
            this._numsMc = arg1.clip;
            this.setNums(this._num);
            return;
        }

        /* internal  */setNums(arg1: int): void
        {
            var loc1=arg1 % 10000 / 1000;
            var loc2=arg1 % 1000 / 100;
            var loc3=arg1 % 100 / 10;
            var loc4=arg1 % 10;
            this._thousandsDigit.bitmapData = loc1 != 0 ? this.getNumBmd(loc1) : null;
            this._hundredsDigit.bitmapData = loc1 == 0 && loc2 == 0 ? null : this.getNumBmd(loc2);
            this._tensDigit.bitmapData = loc1 == 0 && loc2 == 0 && loc3 == 0 ? null : this.getNumBmd(loc3);
            this._unitsDigit.bitmapData = this.getNumBmd(loc4);
            return;
        }

        /* internal  */getNumBmd(arg1: int): Object /* flash.display.BitmapData */
        {
            this._numsMc.gotoAndStop(arg1 + 1);
            var loc1=new Object /* flash.display.BitmapData */(100, 100, true, 0);
            loc1.draw(this._numsMc);
            return loc1;
        }

        public dispose(): void
        {
            if (this._progressBar && this._progressBar.parent) 
            {
                this._progressBar.parent.removeChild(this._progressBar);
            }
            this._progressBar = null;
            this._timer.removeEventListener(flash.events.TimerEvent.TIMER, this.onTimerEvent);
            this._timer = null;
            return;
        }

        /* internal */ /* var */_progressBar: Object /* flash.display.MovieClip */;

        /* internal */ /* var */_numsMc: Object /* flash.display.MovieClip */;

        /* internal */ /* var */_thousandsDigit: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_hundredsDigit: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tensDigit: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_unitsDigit: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_timer: Object /* flash.utils.Timer */;

        /* internal */ /* var */_num: int;
    }
